package com.woniuxy.service.impl;

import com.woniuxy.entity.Car;
import com.woniuxy.entity.CarType;
import com.woniuxy.mapper.CarMapper;
import com.woniuxy.mapper.CarTypeMapper;
import com.woniuxy.service.CarService;
import com.woniuxy.vo.CarVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class CarServiceImpl implements CarService {
    @Resource
    private CarMapper carMapper;
    @Resource
    private CarTypeMapper carTypeMapper;

    @Override
    public List<CarVO> selectCarByExample(Map<String, Object> map) throws Exception {
        return carMapper.selectCarByExample(map);
    }

    @Override
    public int countCarByExample(Map<String, Object> map) throws Exception {
        return carMapper.countCar(map);
    }

    @Override
    public List<CarType> selectAllCarType() throws Exception {
        return carTypeMapper.selectByExample(null);
    }

    @Override
    public int updateCar(Car car) throws Exception {
        return carMapper.updateByPrimaryKeySelective(car);
    }

    @Override
    public int deleteCar(Integer carId) throws Exception {
        return carMapper.deleteByPrimaryKey(carId);
    }

    @Override
    public int insertCar(Car car) throws Exception {
        return carMapper.insertCarReturnKey(car);
    }

    @Override
    public int insertCarById(Car car) throws Exception {
        return carMapper.insertSelective(car);
    }
}
